package com.dd.stack.es.controller;

import com.dd.stack.es.pojo.es.EcommerceProductESDO;
import com.dd.stack.es.pojo.req.complex.ProductQueryReq;
import com.dd.stack.es.service.internal.EcommerceProductService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.PageImpl;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/4/20 1:39
 * @Description Ecommerce产品ES API
 */
@Slf4j
@RestController
@Api(tags = "Ecommerce产品ES API")
@RequiredArgsConstructor
@RequestMapping("/es-ecommerce-product")
public class EcommerceProductESController {

    private final EcommerceProductService ecommerceProductService;

    @PostMapping("/search")
    public ResponseEntity<PageImpl<EcommerceProductESDO>> searchProducts(@RequestBody ProductQueryReq queryReq) {
        PageImpl<EcommerceProductESDO> searchHits = ecommerceProductService.searchProducts(queryReq);
        System.out.println();
        return ResponseEntity.ok(searchHits);
    }
}
